# List(列表)
# create
print("~~~~~~~~~~~~create~~~~~~~~~~~~~~~~")
l = []
l.append("a")
print(l)
l += ['b']
print(l)
l *= 2
print(l)
l.insert(0, 'e')
print(l)

# retrieve
print("~~~~~~~~~~~~~retrieve~~~~~~~~~~~~~")
print(l[0])
# 取一段区间
print(l[0:3])
# 取最后一个值
print(l[-1])
# 间隔问题
print(l[0::2])

# index
print("~~~~~~~~~~~~~index~~~~~~~~~~~~~")
print(l.index('a'))

# Update(更新)
print("~~~~~~~~~~~~~Update~~~~~~~~~~~~~")
l[0] = 'a_1'
print(l)
# 切片赋值
l[0:2] = 'a'
print(l)

# DELETE
print("~~~~~~~~~~~~~DELETE~~~~~~~~~~~~~")
x = l.pop()
print(l)

# SORT
l2 = [2, 1, 4, 3]
l2.sort()
print(l2)
l2.reverse()
print(l2)

# dict
print("~~~~~~~~~~~~~dict~~~~~~~~~~~~~")
d = {}
d['a'] = 1
print(d)
d2 = {"b": 2, "c": 3}
d.update(d2)
print(d)
d.setdefault('d', 0)
print(d)
print(d.get('c', 0))
print(d.keys())
print(d.values())
print(d.items())
# update
d.update({"b": 200, "c": 300})
print(d)
# delete
d.pop("a")
print(d)

# set
print("~~~~~~~~~~~~~set~~~~~~~~~~~~~")
s = set()
s.add("a")
print(s)
# Retrieve
print("a" in s)
# update
s2 = {"b", "c"}
s3 =s.union(s2)
print(s3)
# delete
s3.remove("a")
print(s3)
s3.pop()
print(s3)